package com.yuanfeng.commoms.util;

import com.yuanfeng.commoms.vo.user.UserInfoVO;

/**
 * @ClassName LimitService
 * @Description
 * @Author hyq
 * @Date 2023/7/18 10:03
 * @Version 1.0
 **/

public class LimitUtils {

    // 判断权限信息
    public static Boolean checkLimit(String limit, UserInfoVO platformUserInfo) {
        String limits = platformUserInfo.getRightsLimitsAll();

        // 判断是否是超级管理员
        if (platformUserInfo.getRightsGroupId() == 1) {
            return true;
        }
        // 判断是否为-1，如果！= -1 ，则有权限，返回true
        return (limits.indexOf(limit) != -1);
    }


    public static Boolean containLimits(UserInfoVO userInfo, String limit) {
        Integer adminInteger = userInfo.getSellerIsAdmin();
        if (1 == adminInteger) {
            return true;
        }
        String limitsString = userInfo.getLimits();
        if (null == limitsString) {
            return false;
        }
//		String[] limits = limitsString.split(",");
//		Set<String> limitsSet = new HashSet<String>(Arrays.asList(limits));
//		Boolean torf = limitsSet.contains(limit);
        return true;
    }
}
